package abc.demo3;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.LockSupport;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-12-28
 * Time: 15:04
 */

public class Main {

    private static Thread t1;
    private static Thread t2;
    private static Thread t3;

    public static void main(String[] args) throws InterruptedException {
        Lock lock = new ReentrantLock();
        ParkUnPark parkUnPark = new ParkUnPark(4);
        t1 = new Thread(()->{
           parkUnPark.print("a",t2);
        });
        t2 = new Thread(()->{
            parkUnPark.print("b",t3);
        });
        t3 = new Thread(()->{
            parkUnPark.print("c",t1);
        });
        t1.start();
        t2.start();
        t3.start();
        Thread.sleep(1000);
        LockSupport.unpark(t1);
    }
}